/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package alexpaz.clasesbase;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 *
 * @author Alex
 */
public abstract class DialogoSeleccion extends javax.swing.JDialog {

    public abstract void accionSeleccionarItem();
    public abstract void accionCerrarVentana();

    public TablaSeleccionDTO getTabla() {
        return tablaSeleccionDTO;
    }

    public void setModelo(AbstractDTOTableAdapter modelo) {
        tablaSeleccionDTO.setModel(modelo);
    }

    public DialogoSeleccion(java.awt.Frame parent, boolean modal, AbstractDTOTableAdapter modelo) {

        super(parent, modal);
        initComponents();
        setModelo(modelo);
        tablaSeleccionDTO.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                if (e.getClickCount() == 2) {
                    accionSeleccionarItem();
                }
            }
        });
        addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent e) {
                super.windowClosed(e); 
                accionCerrarVentana();
            }
            
            

        });
        setLocationRelativeTo(parent);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        scroll = new javax.swing.JScrollPane();
        tablaSeleccionDTO = new alexpaz.clasesbase.TablaSeleccionDTO();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Seleccione un Item");
        setModal(true);

        tablaSeleccionDTO.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        scroll.setViewportView(tablaSeleccionDTO);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane scroll;
    private alexpaz.clasesbase.TablaSeleccionDTO tablaSeleccionDTO;
    // End of variables declaration//GEN-END:variables
}
